package com.itheima.demo.demo11;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class keHu {
    public static void main(String[] args) throws IOException {
        File file=new File("D:\\诗.jpg");
        if(file.exists()&&file.length()<2*1024*1024&&file.getName().endsWith("jpg")){
            FileInputStream fis=new FileInputStream("D:\\诗.jpg");
            Socket client=new Socket("192.168.35.37",8888);
            OutputStream os = client.getOutputStream();
            int len=0;
            byte[]b=new byte[1024];
            while ((len=fis.read(b))!=-1){
                //将读到的数据发给服务器
                os.write(b,0,len);
            }
            System.out.println("客户端文件发送完毕");



        }

    }
}
